using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace NoteManger
{
	public class FrmChangeGroup : Form
	{
		private IContainer components = null;
		private ComboBox cbbGroupName;
		private Label label1;
		private Button btnClose;
		private Button btnOK;
		private ComboBox cbbGroupID;
		private string[,] aGroupList = new string[0, 0];
		public string _DepID = "";
		public string _UserID = "";
		public string _UserName = "";
		private NoteRemote _NoteRemoteObject = null;
		private TLoginInfo _LoginInfo = new TLoginInfo();
		public NoteRemote NoteRemoteObject
		{
			set
			{
				this._NoteRemoteObject = value;
			}
		}
		public TLoginInfo LoginInfo
		{
			set
			{
				this._LoginInfo = value;
			}
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.cbbGroupName = new ComboBox();
			this.label1 = new Label();
			this.btnClose = new Button();
			this.btnOK = new Button();
			this.cbbGroupID = new ComboBox();
			base.SuspendLayout();
			this.cbbGroupName.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.cbbGroupName.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbGroupName.FormattingEnabled = true;
			this.cbbGroupName.Location = new System.Drawing.Point(83, 25);
			this.cbbGroupName.Name = "cbbGroupName";
			this.cbbGroupName.Size = new System.Drawing.Size(220, 20);
			this.cbbGroupName.TabIndex = 11;
			this.label1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(24, 28);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(53, 12);
			this.label1.TabIndex = 10;
			this.label1.Text = "选择组名";
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnClose.Location = new System.Drawing.Point(187, 75);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(86, 23);
			this.btnClose.TabIndex = 16;
			this.btnClose.Text = "关闭(&C)";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.btnOK.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnOK.Location = new System.Drawing.Point(62, 75);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(86, 23);
			this.btnOK.TabIndex = 17;
			this.btnOK.Text = "确定(&O)";
			this.btnOK.UseVisualStyleBackColor = true;
			this.btnOK.Click += new EventHandler(this.btnOK_Click);
			this.cbbGroupID.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.cbbGroupID.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbGroupID.FormattingEnabled = true;
			this.cbbGroupID.Location = new System.Drawing.Point(309, 25);
			this.cbbGroupID.Name = "cbbGroupID";
			this.cbbGroupID.Size = new System.Drawing.Size(29, 20);
			this.cbbGroupID.TabIndex = 18;
			this.cbbGroupID.Visible = false;
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new System.Drawing.Size(340, 110);
			base.Controls.Add(this.cbbGroupID);
			base.Controls.Add(this.btnOK);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.cbbGroupName);
			base.Controls.Add(this.label1);
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "FrmChangeGroup";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "用户转组 - 选择新组名";
			base.Shown += new EventHandler(this.FrmChangeGroup_Shown);
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public FrmChangeGroup()
		{
			this.InitializeComponent();
		}
		private void GetGroupList(string aDepID)
		{
			if (this._NoteRemoteObject != null)
			{
				string text = "";
				bool flag = false;
				try
				{
					flag = this._NoteRemoteObject.GetGroupList(aDepID, ref this.aGroupList, ref text);
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				if (flag)
				{
					int num = this.aGroupList.GetUpperBound(0) - this.aGroupList.GetLowerBound(0) + 1;
					int num2 = this.aGroupList.GetUpperBound(1) - this.aGroupList.GetLowerBound(1) + 1;
					for (int i = 0; i <= num - 1; i++)
					{
						this.cbbGroupID.Items.Add(this.aGroupList[i, 0]);
						this.cbbGroupName.Items.Add(this.aGroupList[i, 1]);
					}
				}
				else
				{
					MessageBox.Show(text, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
			}
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void FrmChangeGroup_Shown(object sender, EventArgs e)
		{
			this.GetGroupList(this._DepID);
		}
		private void btnOK_Click(object sender, EventArgs e)
		{
			int selectedIndex = this.cbbGroupName.SelectedIndex;
			if (selectedIndex != -1)
			{
				string aNewGroupID = this.cbbGroupID.Items[selectedIndex].ToString();
				if (MessageBox.Show(string.Concat(new string[]
				{
					"确定要把[",
					this._UserID,
					",",
					this._UserName,
					"]转到“",
					this.cbbGroupName.Text,
					"”组吗？"
				}), "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) != DialogResult.No)
				{
					try
					{
						if (!this._NoteRemoteObject.ConnectionTest())
						{
							MessageBox.Show("远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
							return;
						}
					}
					catch (Exception ex)
					{
						MessageBox.Show(ex.Message + "远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
						return;
					}
					string text = "";
					bool flag = false;
					try
					{
						flag = this._NoteRemoteObject.ChangeUserGroup(this._UserID, aNewGroupID, ref text);
					}
					catch (Exception ex)
					{
						MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					}
					if (!flag)
					{
						MessageBox.Show(text, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					}
					else
					{
						MessageBox.Show("用户转组成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
						base.Close();
					}
				}
			}
		}
	}
}
